#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
const int MOD = 1e9;
long long a[MAXN];
int main() {
  int n, k;
  cin >> n >> k;

  for (int i = 0; i <= k - 1; i++) {
    a[i] = 1ll;
  }
// 滑动窗口

  long long sum = k;
  for (int i = k; i <= n; i++) {
    a[i] = sum;
    // cout << a[i] << endl;
    (sum = sum + a[i] - a[i - k] + MOD) % MOD;  //+MOD 要注意
  }

  cout << a[n];
  return 0;
}